package com.simon.jkxj.ui.conditioning;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.Fragment;

import com.simon.jkxj.R;
import com.simon.jkxj.ui.diagnostic.RespiratoryDiagnosisActivity;
import com.simon.jkxj.ui.consultation.DoctorListActivity;
import com.simon.jkxj.ui.diet.DietGuidanceActivity;
import com.simon.jkxj.ui.conditioning.HealthSelfTestActivity;

public class ConditioningFragment extends Fragment {

    private EditText searchBar;
    private ImageView notificationIcon;
    private CardView btnPersonalizedPlan;
    private CardView moduleHealthStatus;
    private CardView moduleConsultation;
    private CardView moduleRespiratoryDiagnosis;
    private CardView moduleDietGuidance;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_conditioning, container, false);
        initViews(view);
        setupListeners();
        return view;
    }

    private void initViews(View view) {
        searchBar = view.findViewById(R.id.search_bar);
        notificationIcon = view.findViewById(R.id.notification_icon);
        btnPersonalizedPlan = view.findViewById(R.id.btn_personalized_plan);
        moduleHealthStatus = view.findViewById(R.id.module_health_status);
        moduleConsultation = view.findViewById(R.id.module_consultation);
        moduleRespiratoryDiagnosis = view.findViewById(R.id.module_respiratory_diagnosis);
        moduleDietGuidance = view.findViewById(R.id.module_diet_guidance);
    }

    private void setupListeners() {
        // 搜索框点击事件
        searchBar.setOnClickListener(v -> {
            Toast.makeText(getContext(), "搜索功能即将上线", Toast.LENGTH_SHORT).show();
        });

        // 通知图标点击事件
        notificationIcon.setOnClickListener(v -> {
            Toast.makeText(getContext(), "消息通知功能即将上线", Toast.LENGTH_SHORT).show();
        });

        // 专属调理方案按钮点击事件
        btnPersonalizedPlan.setOnClickListener(v -> {
            Toast.makeText(getContext(), "正在生成专属调理方案...", Toast.LENGTH_SHORT).show();
        });

        // 设置功能模块的点击事件
        moduleHealthStatus.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), HealthSelfTestActivity.class);
            startActivity(intent);
        });

        moduleConsultation.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), DoctorListActivity.class);
            startActivity(intent);
        });

        moduleRespiratoryDiagnosis.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), RespiratoryDiagnosisActivity.class);
            startActivity(intent);
        });

        moduleDietGuidance.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), DietGuidanceActivity.class);
            startActivity(intent);
        });
    }
} 